#include "database/Client.hpp"
#include "TCPServer.h"
#include "IntegrityDatas.h"
#include "Protocol.h"

void CSProtocol::InfoContact::receiveTreat(TCPConnection &connexion, IData *udata)
{

}

void CSProtocol::InfoContact::sendTreat(TCPConnection &connexion)
{
  if (!connexion.getAuthenticate())
    return;
  Client *client = connexion.getClient();
  std::list<ClientCategory*>::iterator it;
  for (it = client->getFriends().begin(); it != client->getFriends().end(); ++it)
    {
      CSProtocol::Header header = CSProtocol::Header();
      header.spontaneous = true;
      IData *pcmd;
      header.code = CSProtocol::InfoContact::code;
      CSProtocol::InfoContact command = CSProtocol::InfoContact();
      pcmd = &command;
      std::map<std::string, Client*> &lclts = connexion.getServer()->getDB().getClients();
      strcpy(command.login, (*it)->getLogin().c_str());
      header.dataLength = sizeof(CSProtocol::InfoContact);
      connexion.write(header, *pcmd);
    }
}
